.org 0xDF7F8 ; Vision Increase

Vision_Increase:

	PUSH 	{R4-R6, LR}
	
	LDR 	R2, [Vision_Increase_1]
	LDR 	R1, [Vision_Increase_2]
	LDR 	R2, [R2, 0]
	LDR 	R1, [R1, 0]
	MOV 	R6, R0
	ADD 	R0, R1, R2, LSL 2
	LDR 	R1, [R0, 0x48]
	MOV 	R5, 0
	LDRB 	R0, [R1, 0x5D]
	CMP 	R0, 0
	BEQ 	Vision_Equal
	ADD 	R0, R1, 0x5000
	LDR 	R1, [R0, 0xA58]
	MOV 	R0, 0x98
	MLA 	R1, R6, R0, R1
	LDRB 	R0, [R1, 0x6C]
	LDR 	R1, [R1, 0x6C]
	LDR 	R2, [Vision_Increase_3]
	AND 	R3, R0, 0x7F
	MOV 	R0, 0x220
	MLA 	R0, R3, R0, R2
	MOV 	R1, R1, LSL 0x14
	MOV 	R1, R1, LSR 0x1E
	MOV 	R1, R1, LSL 0x7
	LDRSH 	R0, [R1, R0]
	ADD 	R5, R5, R0

Vision_Equal:	
	BL 		Vision_Increase_Sub
	CMP 	R0, 0
	BNE 	No_Vision_Increase

	LDR 	R1, [Vision_Increase_2]
	LDR 	R0, [Vision_Increase_1]
	LDR 	R2, [R1, 0]
	LDR 	R1, [R0, 0]
	MOV 	R0, 0x98
	ADD 	R1, R2, R1, LSL 2
	MUL 	R4, R6, R0
	LDR 	R1, [R1, 0x48]
	ADD 	R0, R1, 0x5000
	LDR 	R0, [R0, 0xA58]
	
	MOV 	R1, Rank_Scout						; Rank: Scout
	
	ADD 	R0, R0, R4
	ADD 	R0, R0, 0x74
	
	BL 		Check_Skills_Equipped				; Check the Skill is equipped
		
	CMP 	R0, 0								; Does CO use that skill?
	
	LDR 	R1, [Vision_Increase_2]
	LDR 	R0, [Vision_Increase_1]
	LDR 	R2, [R1, 0]
	LDR 	R0, [R0, 0]
	
	MOV 	R1, Rank_Eagle_Eye					; Rank: Eagle Eye
	
	ADD 	R0, R2, R0, LSL 2
	LDR 	R0, [R0, 0x48]
	
	ADDNE 	R5, R5, 1							; If CO use skill, increase vision by 1
	
	ADD 	R0, R0, 0x5000
	LDR 	R0, [R0, 0xA58]
	ADD 	R0, R0, R4
	ADD 	R0, R0, 0x74
	
	BL 		Check_Skills_Equipped				; Check the Skill is equipped
	
	CMP 	R0, 0								; Does CO use that skill?
	
	ADDNE 	R5, R5, 2							; If CO use skill, increase vision by 2

No_Vision_Increase:	
	MOV 	R0, R5
	
	POP 	{R4-R6, LR}
	BX 		LR

;-------------------------------------------------------------------------------		

Vision_Increase_1:
	.dw Reg2_Skill
	
Vision_Increase_2:
	.dw Reg1_Skill
	
Vision_Increase_3:
	.dw 0x021536C4

.org 0xE8AE4
Vision_Increase_Sub:
		


